package com.jie.controller;

import com.jie.pojo.Schedule;
import com.jie.pojo.Student;
import com.jie.service.Impl.ScheduleServiceImpl;
import com.jie.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/schedule")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    @RequestMapping("/getAllClass")
    @ResponseBody
    public List<Schedule> getUserById(HttpServletRequest request, String teacherid) throws Exception {

        List<Schedule> scheduleList = scheduleService.findAllClass(teacherid);
        return scheduleList;
    }

    @RequestMapping("/insertClass")
    @ResponseBody
    public Boolean insertClass(HttpServletRequest request, Schedule schedule) throws Exception {

        Boolean IsSuccess = scheduleService.insertClass(schedule);
        return IsSuccess;
    }

    @RequestMapping("/insertStudent")
    @ResponseBody
    public Boolean insertStudent(HttpServletRequest request, Student student) throws Exception {

        Boolean IsSuccess = scheduleService.insertStudent(student);
        return IsSuccess;
    }
}
